@model SealManagement.Models.SignMaker

@{
    ViewData["Title"] = "编辑制章人";
}

<!DOCTYPE html>

<html>
<head>
	
	<script src="~/js/utils.js"></script>
    <script src="~/lib/jquery/jquery-1.12.4.js"></script>
    <script src="~/lib/jquery/jquery-1.12.4.min.js"></script>
    <script>
        $(function () {
            $('#btnSave').click(function () {
				var base64 = new Base64();
                var UserName = $('#UserName').val();
                var Remark = $('#Remark').val();
                var Id = $('#Id').val();
                EncryptCertList((data) => {
                	data = JSON.parse(data);
let CertID = getCookie("CertID");
                	//加密的字符串
                	var str = JSON.stringify({
						SignMaker:{
							
							UserName: UserName, //用户名
							Remark: Remark, //备注
							Id: Id,
						},
						
						validatecode:"@ViewBag.ValidateCode"
                	});
                
                	var External = {
                		CertID: CertID,
                		//编码
                		DataBase64: base64.encode(str)
                	};
                
                	ExternalEncrypt(JSON.stringify(External), (data) => {
                		data = JSON.parse(data);
                        if (data.error == "Ok") {
                            var dataToPost = {
                                // ArrayNo: CertID,
                                EncryptData: data.contentBase64
                            };
                            $.ajax({
                                url: "/SignMaker/EditForSignMaker",
                                type: 'POST',
                                // contentType: 'application/json',
                                // dataType: 'JSON',
                                data: dataToPost,
                                success: function (data) {
                                    if (data != null && data.state == '200') {
                                        layer.msg('保存成功', { time: 500 }, function () {
                                            window.location.href = '/SignMaker/Index';
                                        });

                                    } else {
                                        layer.msg(data.message);
                                        $('#UserName').val('')
                                        return;
                                    }
                                }
                            });
                        }  else {
                                layer.msg(data.error)
                            }
                	});
                })
                
            });
        })
    </script>

</head>
<body>

    <h2 style="margin:20px 0">编辑制章人</h2>
    <hr />
    <div class="row">
        <div class="col-md-4">
            <form asp-action="Edit">
                <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                <input type="hidden" asp-for="Id" id="Id" />
                <div class="form-group">
                    <label asp-for="UserName" class="control-label"></label>
                    <input asp-for="UserName" class="form-control" id="UserName" />
                    <span asp-validation-for="UserName" class="text-danger"></span>
                </div>
                @*修改变量名*@
                <div class="form-group">
                    <label asp-for="Remark" class="control-label"></label>
                    <input asp-for="Remark" class="form-control" id="Remark" />
                    <span asp-validation-for="Remark" class="text-danger"></span>
                </div>

                <div class="form-group">
                    <input type="button" value="保存" id="btnSave" class="btn btn-default" />
                </div>
            </form>
        </div>
    </div>

    <div>
        <a asp-action="Index">返回列表页面</a>
    </div>

</body>
</html>
